package com.uatair.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.uatair.system.service.ITpUavTaskService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uatair.common.annotation.Log;
import com.uatair.common.core.controller.BaseController;
import com.uatair.common.core.domain.AjaxResult;
import com.uatair.common.enums.BusinessType;
import com.uatair.system.domain.TpUavTask;
import com.uatair.common.utils.poi.ExcelUtil;
import com.uatair.common.core.page.TableDataInfo;

/**
 * 飞机主Controller
 * 
 * @author uatair
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/system/uav")
public class TpUavController extends BaseController
{
    @Autowired
    private ITpUavTaskService tpUavTaskService;

    /**
     * 查询飞机主列表
     */
    @PreAuthorize("@ss.hasPermi('system:uav:list')")
    @GetMapping("/list")
    public TableDataInfo list(TpUavTask tpUavTask)
    {
        startPage();
        List<TpUavTask> list = tpUavTaskService.selectTpUavTaskList(tpUavTask);
        return getDataTable(list);
    }

    /** 
     * 导出飞机主列表
     */
    @PreAuthorize("@ss.hasPermi('system:uav:export')")
    @Log(title = "飞机主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TpUavTask tpUavTask)
    {
        List<TpUavTask> list = tpUavTaskService.selectTpUavTaskList(tpUavTask);
        ExcelUtil<TpUavTask> util = new ExcelUtil<TpUavTask>(TpUavTask.class);
        util.exportExcel(response, list, "飞机主数据");
    }

    /**
     * 获取飞机主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:uav:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tpUavTaskService.selectTpUavTaskById(id));
    }

    /**
     * 新增飞机主
     */
    @PreAuthorize("@ss.hasPermi('system:uav:add')")
    @Log(title = "飞机主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TpUavTask tpUavTask)
    {
        return toAjax(tpUavTaskService.insertTpUavTask(tpUavTask));
    }

    /**
     * 修改飞机主
     */
    @PreAuthorize("@ss.hasPermi('system:uav:edit')")
    @Log(title = "飞机主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TpUavTask tpUavTask)
    {
        return toAjax(tpUavTaskService.updateTpUavTask(tpUavTask));
    }

    /**
     * 删除飞机主
     */
    @PreAuthorize("@ss.hasPermi('system:uav:remove')")
    @Log(title = "飞机主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tpUavTaskService.deleteTpUavTaskByIds(ids));
    }
}
